package riot.challenge.java.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import riot.challenge.java.achievements.AchievementsManager;
import riot.challenge.java.interfaces.IAchievementsManager;
import riot.challenge.java.interfaces.IPlayerGameStatistics;

public class Game {

	private Map<String, IPlayerGameStatistics> gameStats;

	private List<Player> playerList;
	
	private IAchievementsManager achievementManager;
	
	public Game() {
		
		this.gameStats = new HashMap<String, IPlayerGameStatistics>();
		this.playerList = new ArrayList<Player>();
	}
	
	public boolean addPlayer(Player newPlayer) {
		
		for(Player player : playerList) {
			
			if(player.getName().equalsIgnoreCase(newPlayer.getName())) 
				return false;
		}
		
		this.playerList.add(newPlayer);
		
		return true;
	}
	
	public boolean addPlayerStatistics(String playerName, IPlayerGameStatistics stats) {
		
		if(!this.gameStats.containsKey(playerName)) {
			
			for(Player player : playerList) {
				
				if(player.getName().equalsIgnoreCase(playerName)) {	
					
					this.gameStats.put(playerName, stats);
					return true;			
				}				
			}
		}
		
		return false;
	}

	public void play() {
		// TODO !
	}
}
